package com.test.base.nio1.readtest;

import java.io.IOException;
import java.net.InetSocketAddress;
import java.nio.channels.SocketChannel;
import java.nio.charset.Charset;

public class Client {
    public static void main(String[] args) throws IOException {
        SocketChannel sc = SocketChannel.open();
        sc.connect(new InetSocketAddress("127.0.0.1", 8080));
        /*
        如何使用客户端socket进行发送数据
        sc.write(Charset.defaultCharset().encode("hello!!!"));*/
//        sc.write(Charset.defaultCharset().encode("123123\n"));

//        sc.write(Charset.defaultCharset().encode("123123\nasdasd\n"));
        sc.write(Charset.defaultCharset().encode("1234567890\nasdasd"));
        sc.write(Charset.defaultCharset().encode("1234567890abcdefghi\nasdasd\n"));

        System.out.println("waiting...");
        sc.close(); // 需要协商关闭
    }
}
